<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <canvas id="canvas" width="400" height="400"></canvas>
    <script src="utils.js"></script>
    <script src="ball.js"></script>
    <script>
        window.onload = function () {
            var canvas = document.getElementById('canvas'),
                context = canvas.getContext('2d'),
                ball = new Ball(),
                angleX = 0,
                angleY = 0,
                range = 50,
                centerX = canvas.width / 2,
                centerY = canvas.height / 2,
                speedX = 0.07,
                speedY = 0.11

            function drawFrame() {
                window.requestAnimationFrame(drawFrame, canvas)

                context.clearRect(0, 0, canvas.width, canvas.height)

                ball.x = centerX + Math.sin(angleX) * range
                ball.y = centerY + Math.sin(angleY) * range

                angleX+=speedX
                angleY+=speedY

                ball.draw(context)
            }
            drawFrame()

        }
    </script>
</body>

</html>